﻿@model CustomerModel

@{
    ViewBag.Title = T("Admin.Customers.Customers.EditCustomerDetails").Value;
}

<form method="post" asp-action="Edit" id="customer-form" attr-novalidate='(Model.IsGuest, "novalidate")'>
    <div class="section-header">
        <div class="title">
            <a sm-backto asp-action="List"></a>
            <i class="far fa-user-edit"></i>
            <span>@ViewBag.Title - @(Model.FullName.NullEmpty() ?? (Model.IsGuest ? T("Admin.Customers.Guest") : string.Empty))</span>
        </div>
        <div class="options">
            <zone name="admin_button_toolbar_before" />

            <button type="submit" name="save" value="save" class="btn btn-warning" attr-formnovalidate='(Model.IsGuest, "formnovalidate")'>
                <i class="fa fa-check"></i>
                <span>@T("Admin.Common.Save")</span>
            </button>
            <button type="submit" name="save" value="save-continue" class="btn btn-secondary" attr-formnovalidate='(Model.IsGuest, "formnovalidate")'>
                <span>@T("Admin.Common.SaveContinue")</span>
            </button>

            <a sm-if="Model.DisplayProfileLink" asp-route="CustomerProfile" asp-route-id="@Model.Id" class="btn btn-secondary" target="user-profile">
                <i class="fa fa-up-right-from-square"></i>
                <span>@T("Common.UserProfile")</span>
            </a>

            @if (await Display.ZoneHasWidgetsAsync("admin_button_toolbar_messaging_dropdown"))
            {
                <div class="btn-group">
                    <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown">
                        <i class="fa fa-envelope"></i>
                        <span>@T("Common.Send")</span>
                    </button>
                    <div class="dropdown-menu">
                        <a href="#sendemail-window" data-toggle="modal" class="dropdown-item">@T("Admin.Customers.Customers.SendEmail")</a>
                        <zone name="admin_button_toolbar_messaging_dropdown" />
                    </div>
                </div>
            }
            else
            {
                <a href="#sendemail-window" data-toggle="modal" class="btn btn-secondary">
                    <i class="fa fa-envelope"></i>
                    <span>@T("Admin.Customers.Customers.SendEmail")</span>
                </a>
            }

            <a asp-action="Export" asp-route-id="@Model.Id" class="btn btn-secondary">
                <span>@T("Common.Export")</span>
            </a>

            <button sm-if="!Model.Deleted" type="submit" name="customer-delete" id="customer-delete" value="customer-delete" class="btn btn-danger">
                <i class="far fa-trash-can"></i>
                <span>@T("Admin.Common.Delete")</span>
            </button>
            <confirm button-id="customer-delete" />

            <zone name="admin_button_toolbar_after" />
        </div>
    </div>

    <partial name="_CreateOrUpdate" model="Model" />
</form>

<partial name="_SendEmailWindow" model="new CustomerModel.SendEmailModel { CustomerId = Model.Id }" />

@if (Model.Id != 0)
{
    <partial name="_ChangePasswordPopup" model="new CustomerModel.ChangePasswordModel { Id = Model.Id }" />
}